﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Microsoft.VisualStudio.Shell;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.IO;

namespace TFSExp.ExtendedMerge
{

    /// <summary>
    /// Extensions DialogPage
    /// </summary>
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [CLSCompliant(false), ComVisible(true)]
    public class OptionPageGrid : DialogPage
    {
        private string pIDEPath = "";

        /// <summary>
        /// Gets or sets the IDE path.
        /// </summary>
        /// <value>
        /// The IDE path.
        /// </value>
        [Category("IDE Settings")]
        [DisplayName("Set Visual Studio IDE Path")]
        [Description("Visual Studio IDE Path")]
        [Editor("System.Windows.Forms.Design.FolderNameEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
        public string IDEPath
        {
            get { return pIDEPath; }
            set
            {
                if (!System.IO.File.Exists(value + "\\tf.exe"))
                {
                    MessageBox.Show("Path to Visual Studio IDE folder is incorrect.");
                    pIDEPath = "";
                }
                else
                {
                    pIDEPath = value;
                }
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="OptionPageGrid"/> class.
        /// </summary>
        public OptionPageGrid()
            : base()
        {
            string dtpath = Environment.GetEnvironmentVariable("VS100COMNTOOLS") + "\\..\\IDE";
            if (File.Exists(dtpath + "\\tf.exe")) pIDEPath = dtpath;
        }
    }
}
